﻿using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;

namespace esquireclockscreensaver.Utils
{
    public class BoolToWindowsStateConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return (bool) value ? WindowState.Normal : WindowState.Maximized;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var state = (WindowState) value;
            switch (state)
            {
                case WindowState.Normal:
                    return true;
                case WindowState.Minimized:
                    return false;
                case WindowState.Maximized:
                    return false;
                default:
                    throw new ArgumentOutOfRangeException();
            }
        }
    }
}
